<?php
namespace Admin\Controller;
use Think\Controller;
class CatController extends Controller {
    public function cateadd(){
    	if(IS_POST){
    		$catModel = D('cat');
    		if($catModel->add($_POST)){
    			$this->redirect('admin/cat/catelist');exit;
    		}
    	}
        $this->display();
    }

    public function catelist(){
    	$catModel = D('cat');
    	$this->assign('catlist',$catModel->gettree());
    	$this->display();
    }

    public function cateedit(){
    	$catModel = D('Cat');
    	if(IS_POST){
    		$catModel = D('cat');
    		$cat_id = I('cat_id');
    		if($catModel->where('cat_id='.$cat_id)->save($_POST)){
    			$this->redirect('admin/cat/catelist');exit;
    		}
    	}
    	$this->assign('gettree',$catModel->gettree());
    	$this->assign('catinfo',$catModel->find(I('cat_id')));
    	$this->display();
    }

    public function catedel(){
    	$catModel = D('Cat');
    	if($catModel->delete(I('get.cat_id'))){
    		$this->redirect('admin/cat/catelist');exit;
    	}
    }
}